﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LIS2012.DBUtility
{
    /// <summary>
    /// 异常帮助类
    /// </summary>
    public class ExceptionHelper
    {
        public ExceptionHelper(string message)
        {
            AppDomain.CurrentDomain.SetData("ExceptionMessage", message);
        }
        /// <summary>
        /// 是否出现异常
        /// </summary>
        public static bool Exceptioned
        {
            get
            {
                return string.IsNullOrEmpty(ExceptionHelper.Message) ? false : true;
            }
        }
        /// <summary>
        /// 清除异常信息
        /// </summary>
        public static void Clear()
        {
            AppDomain.CurrentDomain.SetData("ExceptionMessage", null);
        }
        /// <summary>
        /// 获取描述当前异常的消息。
        /// </summary>
        public static string Message
        {
            get
            {
                return AppDomain.CurrentDomain.GetData("ExceptionMessage") == null ? null : AppDomain.CurrentDomain.GetData("ExceptionMessage").ToString();
            }
            set
            {
                AppDomain.CurrentDomain.SetData("ExceptionMessage", value);
            }
        }

    }
}
